
from pymysql import Connection

connection_1 = Connection(
    host= "localhost",  # 主机名（ip）
    port= 3306,         # 端口
    user= "root",       # 账户
    password= "123456"  # 密码
)

print(connection_1.get_server_info())

cursor = connection_1.cursor() # 获取游标对象

connection_1.select_db("test") # 选择数据库

# cursor.execute("create table test_pymysql(id int);")

cursor.execute("select * from student")

results:tuple = cursor.fetchall()
print(results)

connection_1.close() # 关闭连接